//
//  SentViewController.m
//  Ai
//
//  Created by 杜超男 on 2019/3/11.
//  Copyright © 2019年 杜超男. All rights reserved.
//

#import "SentViewController.h"

@interface SentViewController ()<UICollectionViewDelegate , UICollectionViewDataSource , UITableViewDelegate , UITableViewDataSource>
@property (nonatomic , strong)UITableView *tableView;
@property (nonatomic , strong)UICollectionViewFlowLayout *layout;
@property (nonatomic , strong)UICollectionView *collectionView;
@property (nonatomic , strong)NSMutableArray *DataSoureArr;
@property (nonatomic , strong)NSArray *ImageArr;//开心'平静'伤心'愤怒的图片
@property (nonatomic , strong)NSArray *ImageDescribeArr;//开心'平静'伤心'愤怒--的文字
@end
static NSString *reuseCell = @"cell";
@implementation SentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.ImageArr = [[NSArray alloc] init];
    self.ImageArr = @[@"Big-Smile" , @"Smile" , @"Cry" , @"Devil"];
    self.ImageDescribeArr = [[NSArray alloc] init];
    self.ImageDescribeArr = @[@"开心" , @"平静" , @"伤心" , @"愤怒"];
//    self.ImageDescribeArr = [[NSArray alloc] initWithObjects:@"开心" , @"平静" , @"伤心" , @"愤怒", nil];
    self.title = @"已发送";
    self.view.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1];
    self.DataSoureArr = [[NSMutableArray alloc] init];
    // Do any additional setup after loading the view.
    
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(15, 0, self.view.frame.size.width-30, self.view.frame.size.height) style:UITableViewStyleGrouped];
    self.tableView.rowHeight = 500;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    //rgba(247/255.0, 247, 247, 1)
    self.tableView.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1];
    self.tableView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.tableView];
//    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(20, 0, 100, 50)];
//    headerView.backgroundColor = [UIColor greenColor];
//    [self.collectionView addSubview:headerView];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    
    //
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
    
    
    
    
    //网格
    self.layout = [[UICollectionViewFlowLayout alloc] init];
    self.layout.itemSize = CGSizeMake(110, 110);
    self.layout.minimumLineSpacing = 15;
    self.layout.minimumInteritemSpacing = 10;
    self.layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
//    self.layout.sectionInset = UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>);
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 50, self.view.bounds.size.width-30, 300) collectionViewLayout:self.layout];
    self.collectionView.backgroundColor = [UIColor whiteColor];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [cell addSubview:self.collectionView];
    [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseCell];
    
    UIImageView *iconImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 20, 22, 22)];
    iconImage.image = [UIImage imageNamed:_ImageArr[indexPath.section]];
    [cell addSubview:iconImage];
    UILabel *DescribeLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 20, 50, 22)];
    DescribeLabel.text = _ImageDescribeArr[indexPath.section];
    [cell addSubview:DescribeLabel];
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return 44;
    }else{
        return 10;
    }
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
        UILabel *NameLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 15, 50, 15)];
        NameLabel.text = @"王小花";
        NameLabel.textColor = [UIColor blackColor];
        NameLabel.font = [UIFont systemFontOfSize:16];
        [headerView addSubview:NameLabel];
//        headerView.backgroundColor = [UIColor greenColor];
        
        NSDateFormatter *Dateformatter = [[NSDateFormatter alloc] init];
        [Dateformatter setDateFormat:@"yyyy-MM-dd"];
        NSDate *currentDate = [[NSDate alloc] init];
        NSString *DateStr = [Dateformatter stringFromDate:currentDate];
        
        NSDateFormatter *WeekDate = [[NSDateFormatter alloc] init];
        [WeekDate setDateFormat:@"EEEE"];
        NSDate *WeekCurrent = [[NSDate alloc] init];
        NSString*WeekDateStr = [WeekDate stringFromDate:WeekCurrent];
        if ([WeekDateStr isEqualToString:@"Monday"]) {
            WeekDateStr = [[NSString alloc] init];
            WeekDateStr = @"周一";
        }else if ([WeekDateStr isEqualToString:@"Tuesday"]){
            WeekDateStr = [[NSString alloc] init];
            WeekDateStr = @"周二";
        }else if ([WeekDateStr isEqualToString:@"Wednesday"]){
            WeekDateStr = [[NSString alloc] init];
            WeekDateStr = @"周三";
        }else if ([WeekDateStr isEqualToString:@"Thursday"]){
            WeekDateStr = [[NSString alloc] init];
            WeekDateStr = @"周四";
        }else if ([WeekDateStr isEqualToString:@"Friday"]){
            WeekDateStr = [[NSString alloc] init];
            WeekDateStr = @"周五";
        }else if ([WeekDateStr isEqualToString:@"Saturday"]){
            WeekDateStr = [[NSString alloc] init];
            WeekDateStr = @"周六";
        }else if ([WeekDateStr isEqualToString:@"Sunday"]){
            WeekDateStr = [[NSString alloc] init];
            WeekDateStr = @"周日";
        }
        
        UILabel *DateLabel = [[UILabel alloc] initWithFrame:CGRectMake(265, 15, 150, 15)];
        DateLabel.text = [NSString stringWithFormat:@"%@ %@",DateStr , WeekDateStr];
        DateLabel.font = [UIFont systemFontOfSize:13];
        //rgba(153/255.0, 153/255.0, 153/255.0, 1)
        DateLabel.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1];
        [headerView addSubview:DateLabel];
        return headerView;
    }else{
        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 10)];
//        headerView.backgroundColor = [UIColor greenColor];
        return headerView;
    }
    return nil;
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
//    return self.DataSoureArr.count;
    return 6;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseCell forIndexPath:indexPath];
    
    
    cell.backgroundColor = [UIColor redColor];
    return cell;
}
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = NO;
    self.tabBarController.tabBar.hidden = YES;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
